package com.example.rpc_core.protocal;

import lombok.Getter;

/**
 * 定义协议的类型枚举
 */
@Getter
public enum ProtocolMessageTypeEnum {
    REQUEST(0),
    RESPONSE(1),
    HEARTBEAT(2),
    OTHERS(3);
    private int key;

   ProtocolMessageTypeEnum(int key){
       this.key=key;
   }


   public static ProtocolMessageTypeEnum getProtocolMessageTypeEnum(int key) {
       for (ProtocolMessageTypeEnum protocolMessageTypeEnum : ProtocolMessageTypeEnum.values()) {
           if(protocolMessageTypeEnum.getKey()==key){
               return protocolMessageTypeEnum;
           }
       }
       return null;
   }
}
